using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SudokuHelper.Model.Values {
    public class UserValue : IValue {
        #region Private members

        public byte? Value { get; private set; }

        #endregion

        #region Constructors

        public UserValue(byte? value) {
            Value = value;
        }

        #endregion

        #region Implementation of IValue

        public virtual object Accept(IValueVisitor valueVisitor, object arg) {
            return valueVisitor.Visit(this, null);
        }

        #endregion

        #region Implementation of IValueRelation

        public virtual void Dispatch(IValueRelation other, ValueRelationDispatcher dispatcher) {
            dispatcher.Dispatch(this, other);
        }

        public virtual void Dispatch(UserValue userValue, ValueRelationDispatcher dispatcher) {
            dispatcher.Perform(this, userValue);
        }

        public virtual void Dispatch(CalculatedValue calculatedValue, ValueRelationDispatcher dispatcher) {
            dispatcher.Perform(this, calculatedValue);
        }

        public virtual void Dispatch(ValueRange range, ValueRelationDispatcher dispatcher) {
            dispatcher.Perform(this, range);
        }

        #endregion

        #region Overriden members

        public override string ToString() {
            return Value.HasValue ? Value.ToString() : string.Empty;
        }

        #endregion
    }
}